package com.ldatum.crm.action.admin;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.ParentPackage;

import com.ldatum.crm.domain.Contacts;
import com.ldatum.crm.service.ContactsService;
import com.ldatum.crm.serviceImpl.ContactsServiceImpl;

@ParentPackage("admin")

public class ContactsAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Contacts contacts ;
	
	ContactsService contactsService = new ContactsServiceImpl();
	
	private int contactsId;
	
	public void findById(){

		PrintWriter out = null;
		JSONObject json = new JSONObject();
		try{
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("type/html");
			response.setCharacterEncoding("utf-8");
			out = response.getWriter();
			Contacts contacts = contactsService.findById(Contacts.class, contactsId);
			json.accumulate("contacts", contacts);
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			out.println(json.toString());
			out.flush();
			out.close();
		}
	}
	
	public Contacts getContacts() {
		return contacts;
	}

	public void setContacts(Contacts contacts) {
		this.contacts = contacts;
	}

	public int getContactsId() {
		return contactsId;
	}

	public void setContactsId(int contactsId) {
		this.contactsId = contactsId;
	}
	
	

	
	
}
